var app = getApp();

Page({
  data: {
    imgUrls: [],
    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 1000,
    circular: true,
    productData: [],
    proCat:[],
    page: 2,
    index: 2,
    brand:[],
    // 滑动
    imgUrl: [],
    kbs:[],
    lastcat:[],
    course:[],
    classification:[],
    swper:[]
  },
  onLoad: function (options) {
    var that = this;
    this.indexClassification();
    this.indexSwper();

  },
  indexClassification: function () { //首页分类
    var that = this;
    wx.request({
      url: app.api.kzdsurl + app.interface.index_classification,
      method: 'get',
      data: {},
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        var classificationarr = [];

        let jurmurl = [
          "../collage/index",
          "../charter/index"

        ]
        for (var i in res.data.data) {
          let classificationobj = {};
          classificationobj["img"] = res.data.data[i];
          classificationobj["url"] = jurmurl[i];
          classificationarr.push(classificationobj);
        }
        console.log(classificationarr);
        that.setData({
          classification: classificationarr,

        });
        //endInitData
      },
      fail: function (e) {
        wx.showToast({
          title: '网络异常！',
          duration: 2000
        });
      },
    });
  },
  
  indexSwper:function(){ //首页轮播
    var that = this;
    wx.request({
      url: app.api.kzdsurl + app.interface.index_swper,
      method: 'get',
      data: {},
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        //that.initProductData(data);
        that.setData({
          swper: res.data.data,
        });
        //endInitData
      },
      fail: function (e) {
        wx.showToast({
          title: '网络异常！',
          duration: 2000
        });
      },
    });
  },

  onShareAppMessage: function () {
    return {
      title: '宠物美容学校',
      path: '/pages/index/index',
      success: function(res) {
        // 分享成功
      },
      fail: function(res) {
        // 分享失败
      }
    }
  }





});